import { Module } from '@nestjs/common';
import { AuthModule } from './model/auth/auth.module';
import { MenuModule } from './model/menu/menu.module';

import { TypeOrmModule } from '@nestjs/typeorm';
import * as config from 'config';
import { ConfigModule } from '@nestjs/config';
import { UserModule } from './model/user/user.module';
import { RolesModule } from './model/roles/roles.module';
import { FileModule } from './model/file/file.module';
import { DictModule } from './model/dict/dict.module';
import { FriendModule } from './model/friend/friend.module';

const databases = config.get('databases');
@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
    }),
    TypeOrmModule.forRoot({
      type: databases.type,
      host: databases.host,
      port: databases.port,
      username: databases.username,
      password: databases.password,
      database: databases.database,
      synchronize: databases.synchronize,
      autoLoadEntities: true,
    }),
    AuthModule,
    MenuModule,
    UserModule,
    RolesModule,
    FileModule,
    DictModule,
    FriendModule,
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}
